package com.qf.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.pojo.DtsUser;
import com.qf.service.UserService;
import com.qf.util.ResponseUtil;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 用户管理
 * @author mkr
 * @version V1.0
 * @Project java2203-mkr
 * @Package com.qf.controller
 * @Description:
 * @Date 2022/6/19 10:32
 */
@RestController
@RequestMapping("/user")
//解决前后端跨域访问问题
@CrossOrigin("*")
@Api(value = "用户管理：会员列表")
public class UserAdmin {

    @Autowired
    private UserService userService;

    /**
     * 会员列表
     * @return
     */
    @GetMapping("")
    @RequestMapping("/list")
    public Object VipList( String username, String mobile,
                           @RequestParam(defaultValue = "1") Integer page,
                           @RequestParam(defaultValue = "20")Integer limit,
                           @RequestParam(defaultValue = "add_time")String sort,
                           @RequestParam(defaultValue = "desc")String order){

        //获取会员数据
        IPage<DtsUser> vipList = userService.VipList(username, mobile, page, limit, sort, order);

        //获取结果集
        List<DtsUser> list = vipList.getRecords();
        //获取总条数
        long total = vipList.getTotal();

        Map<String , Object> data = new HashMap<>();
        data.put("total", total);
        data.put("items", list);

        return ResponseUtil.ok(data);
    }

    /**
     * 审批
     */
    @PostMapping("/approveAgency")
    public void approveAgency(@RequestBody DtsUser user , Integer settlement_rate){

//        userService.approveAgency(user);

    }


}
